<nz-card class="m-b-2">
  <div class="common-search-wrap">
    <div class="common-search-forms">
      <div class="common-form-item">
        <label class="common-search-label">综合搜索</label>
        <div class="common-search-conrol">
          <input nz-input placeholder="关联单号/交易流水" [(ngModel)]="seachParams.num" />
        </div>
      </div>

      <div class="common-form-item">
        <label class="common-search-label">发生时间</label>
        <div class="common-search-conrol">
          <nz-range-picker
            [(ngModel)]="happenTimes"
            (ngModelChange)="timeChange($event)">
          </nz-range-picker>
        </div>
      </div>

      <div class="common-form-item">
        <label class="common-search-label">收支类型</label>
        <div class="common-search-conrol">
          <nz-select
            nzMode="multiple"
            [nzMaxTagCount]="1"
            nzShowSearch
            nzAllowClear
            nzPlaceHolder="全部"
            [(ngModel)]="incomeExpendSelected">
            <nz-option
              *ngFor="let item of incomeExpenditureOptions"
              [nzLabel]="item.name"
              [nzValue]="item.content">
            </nz-option>
          </nz-select>
        </div>
      </div>

      <div class="common-form-item">
        <button nz-button nzType="primary" class="m-r-8" [nzLoading]="tableParams.tableLoading" (click)="seachData()">查询</button>
        <button nz-button nzType="default" (click)="resetData()">重置</button>
        <!-- <button nz-button nzType="link" (click)="isCollapse = !isCollapse">
          {{ isCollapse ? '收起' : '展开' }}<i nz-icon [nzType]="isCollapse ? 'up' : 'down'" nzTheme="outline"></i>
        </button> -->
      </div>
    </div>
  </div>
</nz-card>

<nz-card>
  <div class="operation-wrap p-b-10">
    <button nz-button nzType="primary" [disabled]="!tableData.length" [nzLoading]="exportLoading" (click)="exportTable()">
      <i nz-icon nzType="export" nzTheme="outline"></i>
      导出
    </button>
  </div>

  <div class="pagination-wrap-position table-wrap">
    <nz-table
      #basicTable
      nzSize="small"
      nzShowSizeChanger
      nzShowQuickJumper
      nzOuterBordered
      [nzFrontPagination]="false"
      [nzLoadingDelay]="100"
      [nzLoading]="tableParams.tableLoading"
      [nzData]="tableData"
      [nzPageSizeOptions]="[5, 10, 20, 50, 100]"
      [nzTotal]="tableParams.total"
      [nzPageIndex]="tableParams.page"
      [nzPageSize]="tableParams.pageSize"
      [nzShowTotal]="totalTemplate"
      (nzPageIndexChange)="onPageIndexChange($event)"
      (nzPageSizeChange)="onPageSizeChange($event)"
    >
      <thead>
        <tr>
          <th nzAlign="center">ID</th>
          <th nzAlign="center">收支类型</th>
          <th nzAlign="center">发生时间</th>
          <th nzAlign="center">账单明细</th>
          <th nzAlign="center">关联单号</th>
          <th nzAlign="center">交易流水</th>
          <th nzAlign="center">收益到账时间</th>
        </tr>
      </thead>

      <tbody>
        <tr *ngFor="let data of basicTable.data; let index = index;">
          <td nzAlign="center">{{ data.id }}</td>
          <td nzAlign="center">{{ typeFilter(data.transactionType) }}</td>
          <td nzAlign="center">{{ data.createTime || '-' }}</td>
          <td nzAlign="center">
            <span [ngClass]="{'color-red': data.changeType == 2, 'color-green': data.changeType != 2}">
              {{ data.changeType == 2 ? ('-' + (data.amount | number : '0.2-2')) : ('+' + (data.amount | number : '0.2-2')) }}
            </span>
          </td>
          <td nzAlign="center">{{ data.businessNo || '-' }}</td>
          <td nzAlign="center">{{ (data.billNo && data.billNo !== '0') ? data.billNo : '-' }}</td>
          <td nzAlign="center">{{ data.accountTime || '-' }}</td>
        </tr>
      </tbody>
    </nz-table>

    <!-- 分页template -->
    <ng-template #totalTemplate let-total>共有 {{ tableParams.total }} 条</ng-template>
  </div>
</nz-card>